﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.ComponentModel;
using Newtonsoft.Json.Converters;

namespace poco
{
    public class Email : PluralField
    {
        public enum EmailType {work, home, other};

        public override string FormatValue(string value)
        {
            // TODO: confirm canonicalization rules
            return value.ToLower();
        }

        [JsonProperty(PropertyName = "type")]
        [JsonConverter(typeof(StringEnumConverter))]
        public EmailType Type { get; set; }

        public override bool Equals(object obj)
        {
            if (!base.Equals(obj)) return false;

            if (obj.GetType() != this.GetType()) return false;

            Email other = (Email)obj;

            if (!Object.Equals(this.Type, other.Type)) return false;

            return true;
        }
    }
}
